package cn.edu.hubu.javaparkinglot.controller;

import cn.edu.hubu.javaparkinglot.VO.ResultVO;
import cn.edu.hubu.javaparkinglot.entity.User;
import cn.edu.hubu.javaparkinglot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/user/check")
    public  ResultVO check(String account){
        //调用UserService中的checkAccount方法进行验证
        ResultVO vo = userService.checkAccount(account);
        return vo;

    }
    @RequestMapping("user/register")
    public  ResultVO register(User user){
        ResultVO vo = userService.saveUser(user);
        return vo;

    }
    @RequestMapping("user/login")
    public  ResultVO login(String account,String pwd){
        ResultVO vo = userService.checkLogin(account,pwd);
        return vo;

    }

}
